package com.into.common.csv.converters;

import com.into.common.csv.CSVConverter;

public class BooleanConverter implements CSVConverter<Boolean> {

	protected String trueString = "TRUE";
	protected String falseString = "FALSE";

	public BooleanConverter(String trueString, String falseString) {
		this.trueString = trueString;
		this.falseString = falseString;
	}

	@Override
	public Boolean fromString(String value) throws Exception {
		if (value.equalsIgnoreCase(this.trueString))
			return true;
		else if (value.equalsIgnoreCase(this.falseString))
			return false;
		else
			return false;
	}

	@Override
	public String toString(Boolean value) throws Exception {
		if (value = true)
			return this.trueString;
		else
			return this.falseString;
	}

}
